package com.neusoft.databus.common.dto;

import java.util.ArrayList;
import java.util.List;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;

import com.neusoft.bizcore.web.dto.AbstractAuditDTO;
import com.neusoft.databus.common.enums.PhysicalConnType;
import com.neusoft.databus.common.enums.ResourceWorkMode;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * 网关DTO
 *
 * @author sunchf
 * @date 2018年12月21日 下午4:33:16
 */
@Getter
@Setter
@ToString
public class GatewayDTO extends AbstractAuditDTO {

    private static final long serialVersionUID = 1L;

    /** 资源编码唯一标识,后台生成 */
    @ApiModelProperty(value = "网关编码，自动生成", required = false, position = 1)
    private String code;

    /** 网关名称 */
    @ApiModelProperty(value = "网关名称", required = true, position = 2)
    @NotBlank(message = "网关名称不能为空")
    @Length(max = 255, message = "网关名称不能超过{max}位")
    private String name;

    /** 网关连接类型 */
    @ApiModelProperty(value = "网关连接类型", required = true, position = 3)
    @NotNull(message = "网关连接类型不能为空")
    private PhysicalConnType physicalConnType;

    /** 网关连接信息 */
    @ApiModelProperty(value = "网关连接信息", required = true, position = 4)
    @NotBlank(message = "网关连接信息不能为空")
    @Length(max = 1023, message = "网关连接信息不能超过{max}位")
    private String config;

    /** 网关工作模式 */
    @ApiModelProperty(value = "网关工作模式", required = true, position = 5)
    @NotNull(message = " 资网关工作模式不能为空")
    private ResourceWorkMode workMode = ResourceWorkMode.PULL;

    /** 建立连接的超时时间（秒），默认2秒 */
    @ApiModelProperty(value = "建立连接超时时间", required = false, position = 6)
    @Max(value = 30, message = "超时时间不能超过{value}秒")
    @Min(value = 1, message = "超时时间不能低于{value}秒")
    public int connectTimeout = 2;

    /** 连接失败后的重试次数，默认不重试 */
    @ApiModelProperty(value = "连接失败后重试次数", required = false, position = 7)
    @Max(value = 3, message = "重试次数不能超过{value}次")
    @Min(value = 0, message = "重试次数不能低于{value}次")
    public int connectRetry = 0;

    /** 禁用标识 */
    @ApiModelProperty(value = "禁用标识", required = false, position = 9)
    private boolean disabled = false;

    /** 关联资源 */
    @ApiModelProperty(value = "关联资源", required = false, position = 10)
    private List<ResourceDTO> resources = new ArrayList<>();

    /** 资源组量(列表查询时, 显示资源组量) */
    @ApiModelProperty(value = "资源组量", required = false, position = 11)
    private int resourceSize = 0;

    /** 注释 */
    @ApiModelProperty(value = "注释", required = false, position = 12)
    private String comment;

    /** 关联资源是否批量采集 */
    private boolean batched = false;

    /** 集群节点ID */
    private int node = 0;
}
